package movee.spring.cloud.gateway.service;

import io.jsonwebtoken.Claims;
import io.jsonwebtoken.Jwts;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

/**
 *
 * @author 54740559@qq.com
 */
@Service
@Slf4j
public class SecurityService {

    @Value("${security.jwt.secret}")
    private String secret;

    public Claims getClaims(String token) {

        Claims claims = null;
        try {
            claims = Jwts.parser()
                    .setSigningKey(secret).parseClaimsJws(token)
                    .getBody();
        } catch (Exception e ) {
            log.info("Token is not valid. token: {} ", token);
        }
        return claims;
    }
}
